package com.matt.domain;

import com.matt.foundation.model.Domain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;

/**
 * *******************************
 * description：产品
 * Created by Ron.
 * form com.matt
 * on 2018/6/12
 * *******************************
 */
@Entity
@Data
@EqualsAndHashCode(callSuper = true)
@Table(name = "product")
public class Product extends Domain{

    @Column(columnDefinition = "varchar(50) COMMENT '产品编号'")
    private String code;

    @Column(columnDefinition = "varchar(255) COMMENT '名称'")
    private String name;

    @Column(columnDefinition = "int default 1 COMMENT '是否可用(是否提供数据分析报告)  O:不可用   1：可用'")
    private Integer isVisible=1;

    @Column(columnDefinition = "int default 1 COMMENT '托班类型 1:月托， 2：全日托，3：半日托'" )
    private Integer productDetailType;

    @Column(columnDefinition = "int default 1 COMMENT '类型 1：托班，2:早教，3：其它  4：摄像头  5：订金'")
    private Integer type;

    @Column(columnDefinition = "bit(1) default 0 COMMENT '是否可以主动购买'")
    private Boolean initiable = false;

    @Column(columnDefinition = "int(3) default 0 COMMENT '退费策略  0不退费 1全额 2固定 3手动填写 4出勤率 5小象湾'")
    private Integer refundPolicy;

    @Column(columnDefinition = "int(11) default 0 COMMENT '退费常量，取决于策略需要'")
    private Integer refundConst;

    @Column(precision = 12, scale = 2, columnDefinition = "decimal(12, 2) default 0  COMMENT '标准单位价格'")
    private BigDecimal standardAmount;

    @Column(columnDefinition = "varchar(50) COMMENT '单位'")
    private String unit;

    @Column(columnDefinition = "varchar(32) COMMENT '所属园区'")
    private String areaId;

    @Column(columnDefinition = " int(3) DEFAULT 0 COMMENT '审核状态 0.待审核  1.审核通过  2.审核拒绝' ", nullable = false)
    public Integer audited = 0;

    public static Product of(String code,String name,Integer isVisible,Integer type,BigDecimal standardAmount,String unit,String areaId){
        Product vo = new Product();
        vo.setName(name);
        vo.setCode(code);
        vo.setIsVisible(isVisible);
        vo.setType(type);
        vo.setStandardAmount(standardAmount);
        vo.setUnit(unit);
        vo.setAreaId(areaId);
        return vo;
    }
}
